{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:32:02.077506Z",
     "start_time": "2024-02-21T02:32:02.074835Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'r', 'b', 'g'}\n"
     ]
    }
   ],
   "source": [
    "#内置数据类型\n",
    "#集合Set\n",
    "color = ('r', 'g', 'b', 'g', 'b', 'b')  # tuple\n",
    "new_color = set(color)  # set\n",
    "print(new_color)"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('r', 'b', 'g')\n"
     ]
    }
   ],
   "source": [
    "new_color_2 = tuple(new_color) # tuple\n",
    "print(new_color_2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:34:39.395733Z",
     "start_time": "2024-02-21T02:34:39.391859Z"
    }
   },
   "id": "dabcb3fa5496c1c0",
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'new_color_2' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mNameError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[0;32mIn[4], line 2\u001B[0m\n\u001B[1;32m      1\u001B[0m \u001B[38;5;28;01mdel\u001B[39;00m new_color_2\n\u001B[0;32m----> 2\u001B[0m \u001B[38;5;28mprint\u001B[39m(\u001B[43mnew_color_2\u001B[49m)\n",
      "\u001B[0;31mNameError\u001B[0m: name 'new_color_2' is not defined"
     ]
    }
   ],
   "source": [
    "del new_color_2\n",
    "print(new_color_2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T02:36:18.816059Z",
     "start_time": "2024-02-21T02:36:18.702120Z"
    }
   },
   "id": "8174a9d14d3102c9",
   "execution_count": 4
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'b', 'r', 'g'}\n"
     ]
    }
   ],
   "source": [
    "list1 = ['r', 'g','b', 'g','b', 'r', 'g']\n",
    "list2 = set(list1)\n",
    "print(list2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T07:13:05.325550Z",
     "start_time": "2024-02-21T07:13:05.322899Z"
    }
   },
   "id": "c8dba9dd7b56e707",
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('b', 'r', 'g')\n"
     ]
    }
   ],
   "source": [
    "new_tuple = tuple(list2)\n",
    "print(new_tuple)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T07:13:06.446236Z",
     "start_time": "2024-02-21T07:13:06.444160Z"
    }
   },
   "id": "3b3dd39a8d9ee518",
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print('r' in new_tuple)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-02-21T07:13:22.432957Z",
     "start_time": "2024-02-21T07:13:22.424853Z"
    }
   },
   "id": "4c21cb09b777bdae",
   "execution_count": 4
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
